import { createStore, applyMiddleware } from 'redux';
import thunk from 'redux-thunk';
import rootReducer from '../reducers/reducers';

export default function configureStore(initialState) {
	const store = createStore(rootReducer, initialState, applyMiddleware(thunk));
	if (module.hot) {
		module.hot.accept('../reducers/reducers', () => {
			const nextReducer = require('../reducers/reducers').default
			store.replaceReducer(nextReducer)
		})
	}
	return store
}
